package gui.room;

import gui.alert;
import pojo.Guestroominfo;
import service.roomService;

import javax.swing.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class add_room {
    private JPanel add_room;
    private JButton confirm_add_Button;
    private JTextField room_type;
    private JTextField fee;
    private JTextField textField1;

    public add_room() {

        confirm_add_Button.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                super.mouseClicked(e);
                Guestroominfo guestroominfo = new Guestroominfo();
                guestroominfo.setGstate(textField1.getText());
                guestroominfo.setGrank(room_type.getText());
                guestroominfo.setGrent(Long.valueOf(fee.getText()));

                if (roomService.insert(guestroominfo) == 1) {
                    alert.show("添加成功");
                } else {
                    alert.show("添加失败");
                }
            }
        });
    }

    public static void show() {
        JFrame frame = new JFrame("增加客房");
        frame.setContentPane(new add_room().add_room);
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
    }

}
